<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<f:view xmlns="http://www.w3.org/1999/xhtml"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui"
        xmlns:pm="http://primefaces.org/mobile"
        contentType="text/html"
        locale="#{staffMobileBean.locale}">

    <pm:page title="#{communetext.commune_title} - #{bundle.vinavac}">

        <!-- Main View -->
        <pm:view id="main">
            <pm:header title="#{communetext.commune_title} - #{bundle.vinavac}" >

                <f:facet name="left">                    
                    <p:button value="#{bundle.home}" icon="ui-icon ui-icon-home" href="/faces/admin/index.xhtml"/>
                </f:facet>

                <f:facet name="right">
                    <h:form>
                        <p:commandButton value="#{bundle.new}" icon="plus" action="#{communeMobileBean.prepareCreate}" update=":formNew"/>
                    </h:form>
                </f:facet>
            </pm:header>

            <pm:content>
                <h:form id="formList">
                    <p:dataList id="itemList" value="#{communeMobileBean.items}" var="item">
                        <p:column>
                            <p:commandLink value="#{item}" action="pm:edit" update=":formEdit" style="text-decoration: none">
                                <f:setPropertyActionListener value="#{item}" target="#{communeMobileBean.selected}" />
                            </p:commandLink>
                        </p:column>
                    </p:dataList>
                </h:form>
            </pm:content>
        </pm:view>

        <!-- New item -->
        <pm:view id="new">
            <pm:header title="#{bundle.new} - #{bundle.vinavac}">
                <f:facet name="left"><p:button value="#{bundle.back}" icon="back" href="#main?reverse=true"/></f:facet>
            </pm:header>

            <pm:content>
                <h:form id="formNew">                    
                    <p:inputText id="name" type="text" value="#{communeMobileBean.selected.commune}" label="#{communetext.commnue_name}:"/>
                    <pm:field>
                        <h:outputLabel for="site" value="#{communetext.site}"/>
                        <h:selectOneRadio id="site" value="#{communeMobileBean.selected.site}">
                            <f:selectItem itemValue="North" itemLabel="North"/>
                            <f:selectItem itemValue="Central" itemLabel="Central"/>
                            <f:selectItem itemValue="South" itemLabel="South"/>
                        </h:selectOneRadio>
                    </pm:field>
                    <p:commandButton value="#{bundle.save}" action="#{communeMobileBean.update}" update=":formList:itemList" icon="check" />
                </h:form>
            </pm:content>

        </pm:view>

        <!-- Edit item -->
        <pm:view id="edit">
            <pm:header title="#{bundle.edit} - #{bundle.vinavac}">
                <f:facet name="left"><p:button value="#{bundle.back}" icon="back" href="#main?reverse=true"/></f:facet>
            </pm:header>

            <pm:content>
                <h:form id="formEdit">   
                    <p:inputText id="name" type="text" value="#{communeMobileBean.selected.commune}" label="#{communetext.commnue_name}:"/>
                    <pm:field>
                        <h:outputLabel for="site" value="#{communetext.site}"/>
                        <h:selectOneRadio id="site" value="#{communeMobileBean.selected.site}">
                            <f:selectItem itemValue="North" itemLabel="North"/>
                            <f:selectItem itemValue="Central" itemLabel="Central"/>
                            <f:selectItem itemValue="South" itemLabel="South"/>
                        </h:selectOneRadio>
                    </pm:field>
                    <p:commandButton value="#{bundle.save}" action="#{communeMobileBean.update}" update=":formList:itemList" icon="check" />
                </h:form>
            </pm:content>

        </pm:view>

    </pm:page>

</f:view>
